package com.rosca.converters.number2word.tests;

import com.rosca.converters.number2word.N2WConverter;
import com.rosca.converters.number2word.N2WConverterFactory;
import com.rosca.converters.number2word.NumberTooLargeException;
import com.rosca.converters.number2word.UnsupportedLocaleException;
import org.junit.Before;
import org.junit.Test;

import java.util.Locale;

import static junit.framework.Assert.assertEquals;

/**
 * User: vrosca
 * Date: 7/27/11
 * Time: 11:31 AM
 * &copy; PFA Rosca Val Dan Dar Ion 2011
 */
public class AmericanEnglishConversionTest {
    N2WConverter converter;

    @Before
    public void setupConverter() throws UnsupportedLocaleException {
        converter = N2WConverterFactory.createConverter(Locale.US);
    }

    @Test
    public void convertMinus9999() throws NumberTooLargeException {
        assertEquals("minus nine thousand nine hundred ninety-nine", converter.spell(-9999));
    }

    @Test
    public void convert0() throws NumberTooLargeException {
        assertEquals("zero", converter.spell(0));
    }

    @Test
    public void convert1() throws NumberTooLargeException {
        assertEquals("one", converter.spell(1));
    }

    @Test
    public void convert21() throws NumberTooLargeException {
        assertEquals("twenty-one", converter.spell(21));
    }

    @Test
    public void convert56945781() throws NumberTooLargeException {
        assertEquals("fifty-six million nine hundred forty-five thousand seven hundred eighty-one", converter.spell(56945781));
    }

    @Test
    public void convert999999999() throws NumberTooLargeException {
        assertEquals("nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine", converter.spell(999999999));
    }
}
